#include <stdio.h>
#include <wiringPi.h>
#include <wiringSerial.h>   //串口的头文件

int serail_fd = 0;			//串口文件描述符

int main(int argc, char *argv[]){
    printf("Hello World!\n");
    if(wiringPiSetup() == -1){
        printf("setup wiringPi failed !");
        return 1;
    }
    printf("Hello world!\n");
	//树莓派串口初始化
    if((serail_fd = serialOpen("/dev/ttyAMA0",115200)) < 0)
    {
        return 0;
    }
    serialPrintf(serail_fd,"Hello world\n"); //串口输出字符串
    while(1){
        char res = serialGetchar(serail_fd); //串口获取字符
        serialPutchar(serail_fd, res);		 //串口发送字符
        printf("%c", res);
    }
    return 0;
}




